import React, { Component } from 'react';
import Message from './Message';
import News from './News';
import MyLink from '../../components/MyLink';
import { Switch, Route, Redirect } from 'react-router-dom';

export default class Home extends Component {
    render() {
        return (
            <div>
                <h2>Home组件内容</h2>
                <div>
                    <ul className="nav nav-tabs">
                        <li>
                            {/* 默认的Link是push模式的，我们可以开启replace模式 */}
                            <MyLink to='/home/message' replace={true}>Message</MyLink>
                        </li>
                        <li>
                            <MyLink to='/home/news' replace={true}>News</MyLink>
                        </li>
                    </ul>
                    <Switch>
                        <Route path='/home/message' component={Message} />
                        <Route path='/home/news' component={News} />
                        <Redirect to='/home/message' />
                    </Switch>
                </div>
            </div>
        )
    }
}
